package com.whcoding.designpatterns.pattern.prototype;

/**
 * @program: spring-boot-learning
 * @description: 具体角色 - 克隆羊
 * @author: whcoding
 * @create: 2022-09-21 16:17
 **/
public class CloneSheepImpl implements ISheep {


	private String name;

	private Integer age;

	private String color;

	public CloneSheepImpl(String name, Integer age, String color) {
		this.name = name;
		this.age = age;
		this.color = color;
	}

	@Override
	public String toString() {
		return "Sheep{" +
				"name='" + name + '\'' +
				", age='" + age + '\'' +
				", color='" + color + '\'' +
				'}';
	}


	/**
	 * 实现克隆方法
	 *
	 * @return
	 */
	@Override
	public SheepVO clone() {
		try {
			return (SheepVO) super.clone();
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
			return null;
		}
	}
}
